<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>QSculpt: engine/include/IIterator.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">QSculpt
   &#160;<span id="projectnumber">0.0.1a</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">engine/include/IIterator.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *  IIterator.h</span>
<a name="l00003"></a>00003 <span class="comment"> *  QSculpt</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> *  Created by Roberto Cabral on 1/7/10.</span>
<a name="l00006"></a>00006 <span class="comment"> *  Copyright 2010 Juan Roberto Cabral. All rights reserved.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> */</span>
<a name="l00009"></a>00009 
<a name="l00010"></a>00010 <span class="preprocessor">#ifndef IITERATOR_H_</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span><span class="preprocessor">#define IITERATOR_H_</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span>
<a name="l00013"></a>00013 <span class="comment">// TODO: Check if it the need to optimize iterator design. To many indirections?</span>
<a name="l00014"></a>00014 
<a name="l00018"></a>00018 <span class="keyword">enum</span> IteratorOrigin
<a name="l00019"></a>00019 {
<a name="l00020"></a>00020     Iter_Start,
<a name="l00021"></a>00021     Iter_Current,
<a name="l00022"></a>00022     Iter_End
<a name="l00023"></a>00023 };
<a name="l00024"></a>00024 
<a name="l00028"></a>00028 <span class="keyword">template</span>&lt; <span class="keyword">typename</span> T &gt;
<a name="l00029"></a><a class="code" href="class_i_iterator.html">00029</a> <span class="keyword">class </span><a class="code" href="class_i_iterator.html">IIterator</a>
<a name="l00030"></a>00030 {
<a name="l00031"></a>00031 <span class="keyword">public</span>:
<a name="l00032"></a>00032     <span class="comment">//virtual ~IIterator(){}</span>
<a name="l00033"></a>00033 
<a name="l00037"></a>00037     <span class="keyword">virtual</span> <a class="code" href="class_i_iterator.html">IIterator&lt;T&gt;</a>* <a class="code" href="class_i_iterator.html#a6fdc9a8286cb3fe2d6c9a0edba2fd478">clone</a>() <span class="keyword">const</span> = 0;
<a name="l00038"></a>00038 
<a name="l00043"></a>00043     <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_i_iterator.html#a3110d893d8f9b57c221d76c058675e76">hasNext</a>() <span class="keyword">const</span> = 0;
<a name="l00044"></a>00044 
<a name="l00048"></a>00048     <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_i_iterator.html#aeaf6228da3ecdbe4609f78dea914b49d">hasPrevious</a>() <span class="keyword">const</span> = 0;
<a name="l00049"></a>00049 
<a name="l00053"></a>00053     <span class="keyword">virtual</span> T &amp; <a class="code" href="class_i_iterator.html#abbc47bcea2f56611ce96320d4b6480f5">next</a>() = 0;
<a name="l00054"></a>00054 
<a name="l00058"></a>00058     <span class="keyword">virtual</span> <span class="keyword">const</span> T &amp; <a class="code" href="class_i_iterator.html#abbc47bcea2f56611ce96320d4b6480f5">next</a>() <span class="keyword">const</span> = 0;
<a name="l00059"></a>00059     
<a name="l00063"></a><a class="code" href="class_i_iterator.html#a638bdae1c3dc3f9f40b8be869b7e65a6">00063</a>     <span class="keyword">virtual</span> T &amp; <a class="code" href="class_i_iterator.html#a638bdae1c3dc3f9f40b8be869b7e65a6">peekNext</a>() {
<a name="l00064"></a>00064         NOT_IMPLEMENTED
<a name="l00065"></a>00065     };
<a name="l00066"></a>00066     
<a name="l00070"></a><a class="code" href="class_i_iterator.html#a488527e793d7ae1aa823cd7faf0f01b5">00070</a>     <span class="keyword">virtual</span> <span class="keyword">const</span> T &amp; <a class="code" href="class_i_iterator.html#a488527e793d7ae1aa823cd7faf0f01b5">peekNext</a>()<span class="keyword"> const </span>{
<a name="l00071"></a>00071         NOT_IMPLEMENTED
<a name="l00072"></a>00072     };
<a name="l00073"></a>00073 
<a name="l00078"></a>00078     <span class="keyword">virtual</span> T &amp; <a class="code" href="class_i_iterator.html#a89c5545b5224e7c8b347da9325c44f9d">previous</a>() = 0;
<a name="l00079"></a>00079 
<a name="l00084"></a>00084     <span class="keyword">virtual</span> <span class="keyword">const</span> T &amp; <a class="code" href="class_i_iterator.html#a89c5545b5224e7c8b347da9325c44f9d">previous</a>() <span class="keyword">const</span> = 0;
<a name="l00085"></a>00085 
<a name="l00092"></a>00092     <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_i_iterator.html#a6996f0cd1b32bb80e36b130b7b242b8a">seek</a>(<span class="keywordtype">int</span> pos, IteratorOrigin origin) <span class="keyword">const</span> = 0;
<a name="l00093"></a>00093 };
<a name="l00094"></a>00094 
<a name="l00095"></a>00095 
<a name="l00102"></a>00102 <span class="keyword">template</span>&lt; <span class="keyword">typename</span> T&gt;
<a name="l00103"></a><a class="code" href="class_iterator.html">00103</a> <span class="keyword">class </span><a class="code" href="class_iterator.html">Iterator</a>
<a name="l00104"></a>00104 {
<a name="l00105"></a>00105     <a class="code" href="class_i_iterator.html">IIterator&lt;T&gt;</a> *_it;
<a name="l00106"></a>00106 
<a name="l00107"></a>00107 <span class="keyword">public</span>:
<a name="l00112"></a><a class="code" href="class_iterator.html#a40599bebf780bd35fcb885d5475bcf4e">00112</a>     <a class="code" href="class_iterator.html#a40599bebf780bd35fcb885d5475bcf4e">Iterator</a>(<a class="code" href="class_i_iterator.html">IIterator&lt;T&gt;</a>* it = 0) : _it(it) {}
<a name="l00113"></a>00113 
<a name="l00117"></a><a class="code" href="class_iterator.html#ab2e87dd1cbc330edb7709dfc1e07da02">00117</a>     <a class="code" href="class_iterator.html#ab2e87dd1cbc330edb7709dfc1e07da02">Iterator</a>(<span class="keyword">const</span> <a class="code" href="class_iterator.html">Iterator&lt;T&gt;</a>&amp; cpy) : _it(cpy._it-&gt;clone()) {}
<a name="l00118"></a>00118 
<a name="l00122"></a><a class="code" href="class_iterator.html#ae3ca5d592c9550743e6bfe07e5881c13">00122</a>     <a class="code" href="class_iterator.html#ae3ca5d592c9550743e6bfe07e5881c13">~Iterator</a>() { <span class="keyword">delete</span> _it; _it = NULL;}
<a name="l00123"></a>00123 
<a name="l00127"></a><a class="code" href="class_iterator.html#a1553004116ce9a9daf090da9a7d3edd0">00127</a>     <a class="code" href="class_iterator.html">Iterator</a>&amp; <a class="code" href="class_iterator.html#a1553004116ce9a9daf090da9a7d3edd0">operator=</a>(<span class="keyword">const</span> <a class="code" href="class_iterator.html">Iterator&lt;T&gt;</a>&amp; it) {
<a name="l00128"></a>00128         <span class="keywordflow">if</span> (<span class="keyword">this</span> == &amp;it) <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00129"></a>00129 
<a name="l00130"></a>00130         this-&gt;_it = it._it-&gt;clone();
<a name="l00131"></a>00131         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00132"></a>00132     }
<a name="l00133"></a>00133 
<a name="l00138"></a><a class="code" href="class_iterator.html#a146904d78b57b793a9fc2a5e4a5857d1">00138</a>     <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_iterator.html#a146904d78b57b793a9fc2a5e4a5857d1">hasNext</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _it &amp;&amp; _it-&gt;hasNext(); }
<a name="l00139"></a>00139 
<a name="l00143"></a><a class="code" href="class_iterator.html#ae3b318b740496814a7b9d99f1dd04022">00143</a>     <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_iterator.html#ae3b318b740496814a7b9d99f1dd04022">hasPrevious</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _it &amp;&amp; _it-&gt;hasPrevious(); }
<a name="l00144"></a>00144 
<a name="l00148"></a><a class="code" href="class_iterator.html#ad27bc945f5c433bf84b45fee9c11a8dd">00148</a>     <span class="keyword">inline</span> T &amp; <a class="code" href="class_iterator.html#ad27bc945f5c433bf84b45fee9c11a8dd">next</a>() { 
<a name="l00149"></a>00149         assert(_it != 0);
<a name="l00150"></a>00150         <span class="keywordflow">return</span> _it-&gt;next();
<a name="l00151"></a>00151     }
<a name="l00152"></a>00152 
<a name="l00156"></a><a class="code" href="class_iterator.html#a69e4090a84a85c4ffc2811924d042c1c">00156</a>     <span class="keyword">inline</span> <span class="keyword">const</span> T &amp; <a class="code" href="class_iterator.html#a69e4090a84a85c4ffc2811924d042c1c">next</a>()<span class="keyword"> const </span>{ 
<a name="l00157"></a>00157         assert(_it != 0);
<a name="l00158"></a>00158         <span class="keywordflow">return</span> _it-&gt;next(); 
<a name="l00159"></a>00159     }
<a name="l00160"></a>00160 
<a name="l00164"></a><a class="code" href="class_iterator.html#a02f2498a4f39c21d6444c7f297953ee8">00164</a>     <span class="keyword">inline</span> T &amp; <a class="code" href="class_iterator.html#a02f2498a4f39c21d6444c7f297953ee8">peekNext</a>() { 
<a name="l00165"></a>00165         assert(_it != 0);
<a name="l00166"></a>00166         <span class="keywordflow">return</span> _it-&gt;peekNext();
<a name="l00167"></a>00167     }
<a name="l00168"></a>00168     
<a name="l00172"></a><a class="code" href="class_iterator.html#a68920d39a28e82cfbd143bb2a4bd4ea6">00172</a>     <span class="keyword">inline</span> <span class="keyword">const</span> T &amp; <a class="code" href="class_iterator.html#a68920d39a28e82cfbd143bb2a4bd4ea6">peekNext</a>()<span class="keyword"> const </span>{ 
<a name="l00173"></a>00173         assert(_it != 0);
<a name="l00174"></a>00174         <span class="keywordflow">return</span> _it-&gt;peekNext();
<a name="l00175"></a>00175     }
<a name="l00176"></a>00176     
<a name="l00181"></a><a class="code" href="class_iterator.html#aa57773d32b7a91f896610922454aedfa">00181</a>     <span class="keyword">inline</span> T &amp; <a class="code" href="class_iterator.html#aa57773d32b7a91f896610922454aedfa">previous</a>() { 
<a name="l00182"></a>00182         assert(_it != 0);
<a name="l00183"></a>00183         <span class="keywordflow">return</span> _it-&gt;previous();
<a name="l00184"></a>00184     }
<a name="l00185"></a>00185 
<a name="l00190"></a><a class="code" href="class_iterator.html#a037a5a6cbf34be39e6bcec029809b159">00190</a>     <span class="keyword">inline</span> <span class="keyword">const</span> T &amp; <a class="code" href="class_iterator.html#a037a5a6cbf34be39e6bcec029809b159">previous</a>()<span class="keyword"> const </span>{ 
<a name="l00191"></a>00191         assert(_it != 0);
<a name="l00192"></a>00192         <span class="keywordflow">return</span> _it-&gt;previous();
<a name="l00193"></a>00193     }
<a name="l00194"></a>00194 
<a name="l00201"></a><a class="code" href="class_iterator.html#a42b51cf85536d37b0e172d62a356fb15">00201</a>     <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_iterator.html#a42b51cf85536d37b0e172d62a356fb15">seek</a>(<span class="keywordtype">int</span> pos, IteratorOrigin origin = Iter_Start)<span class="keyword"> const </span>{
<a name="l00202"></a>00202         assert(_it != 0);
<a name="l00203"></a>00203         <span class="keywordflow">return</span> _it-&gt;seek(pos, origin);
<a name="l00204"></a>00204     }
<a name="l00205"></a>00205 };
<a name="l00206"></a>00206 
<a name="l00207"></a>00207 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Sat Aug 27 2011 15:38:52 for QSculpt by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
